package a2;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ReplayingDecoder;

import java.util.List;

//不需要状态管理为Void
public class MyByteToLongDecoder2 extends ReplayingDecoder<Void> {
    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        System.out.println("MyByteToLongDecoder2 decode invoked!");
        //不需要检查bytebuf够不够Long的8个字节，读取Long之前并没有判断in.readableBytes() >= 8。
        //MyByteToLongDecoder读取之前是检查8个字节长度了的。
        out.add(in.readLong());
    }
}
